knitr::opts_chunk$set(echo = TRUE)

library(tidyverse)
## -- Attaching packages --------------------------------------- tidyverse 1.3.1 --
## v ggplot2 3.3.5     v purrr   0.3.4
## v tibble  3.1.6     v dplyr   1.0.7
## v tidyr   1.1.4     v stringr 1.4.0
## v readr   2.1.1     v forcats 0.5.1
## -- Conflicts ------------------------------------------ tidyverse_conflicts() --
## x dplyr::filter() masks stats::filter()
## x dplyr::lag()    masks stats::lag()
library(dplyr)
load("all_guns.RData")
Auto_Rifles %>% filter(Body_dmg > 20)
## # A tibble: 9 x 27
##   Archetype   Weapon       Energy Perk  Effect   RoF Crit_dmg Body_dmg Crit_mult
##   <chr>       <chr>        <chr>  <chr> <lgl>  <dbl>    <dbl>    <dbl>     <dbl>
## 1 High Impact Halfdan-D (~ Kinet~ <NA>  NA       360       35       22       1.6
## 2 High Impact Gahlran's R~ Kinet~ <NA>  NA       360       35       22       1.6
## 3 High Impact Pluperfect ~ Kinet~ <NA>  NA       360       35       22       1.6
## 4 High Impact Age-Old Bon~ Void   <NA>  NA       360       35       22       1.6
## 5 High Impact False Promi~ Kinet~ <NA>  NA       360       35       22       1.6
## 6 High Impact Chrysura Me~ Solar  <NA>  NA       360       35       22       1.6
## 7 High Impact Come to Pas~ Arc    <NA>  NA       360       35       22       1.6
## 8 High Impact Herod-C (Ga~ Stasis <NA>  NA       360       35       22       1.6
## 9 High Impact Vex Mythocl~ Solar  <NA>  NA       390       35       22       1.6
## # ... with 18 more variables: `Optimal_TtK(s)` <dbl>, Opt_Shots <dbl>,
## #   Crit_Percent <chr>, Opt_Crits <dbl>, Opt_Body <dbl>, Bursts...15 <lgl>,
## #   Body_TtK <dbl>, Body_Kill <dbl>, Bursts...18 <lgl>, Impact <dbl>,
## #   Range <dbl>, Stability <dbl>, Handling <dbl>, Reload_Speed <dbl>,
## #   Aim_Assist <dbl>, Recoil_Direction <dbl>, Mag_Size <dbl>, Type <chr>
gun_data <- bind_rows(Auto_Rifles, Bows, Breech_Grenade_Launchers, Fusion_Rifles, Hand_Cannons, Heavy_Grenade_Launchers, Linear_Fusion_Rifles, Machine_Guns, Pulse_Rifles, Rocket_Launchers, Scout_Rifles, Shotguns, Sidearms, Sniper_Rifles, Submachine_Guns, Swords)

view(gun_data)
##Auto Rifles are fully automatic weapons that thrive in close-medium range encounters. Their 2 top values would be RoF and Body Damage.

##There are 9 Auto rifles with more than 390 ROF and more than 20 body damage
top_autos <- Auto_Rifles %>% group_by(Archetype) %>% filter(Body_dmg > 20 & RoF > 350)



##Scouts are semi automatic which specialize in range and precision. Their top two specialties will rely on their Crit damage and Optimal amount of shots for a kill

##
top_scouts <- Scout_Rifles %>% group_by(Archetype) %>% filter(Crit_dmg > 50 & Opt_Shots < 3.1)

#Hand cannons 

##Their top attributes you want to look for are Range, Stability and 
top_hand_cannons <- Hand_Cannons %>% group_by(Archetype) %>% filter(Range > 55 & Stability > 55)

##Pulse Rifles

##Pulse rifles are a ranged weapon that shoot in bursts of 3.4 or 5 and specialize in medium ranged combat

top_pulse <- Pulse_Rifles %>% group_by(Archetype) %>% filter(Range > 55 & Stability > 55 & RoF > 350)

#Sub Machine Guns

#Sub machine guns are fully automatic weapons with very limited range and their defining features are it RoF, Handling and Stability

top_subs <- Submachine_Guns %>% group_by(Archetype) %>% filter(RoF > 700 & Handling > 55 & Stability > 55)

#Bows

#Bows are Long ranges weapons that typically take 2-3 shot to take someone out. What you want to look for in a bow are a quick draw time, high impact, and/or good accuracy.

top_bows <- Bows %>% group_by(Archetype) %>% filter(Draw_Time < 700 & Impact > 70 & Accuracy > 50)

#Fusion Rifles

#Fusion Rifles are energy base weapons which you start with limited ammo and can only be shot twice before needing to pick up from a dead player. The features you look for in a good fusion rifle are Low charge time, Handling and high impact.

top_fusions <- Fusion_Rifles %>% group_by(Archetype) %>% filter(`Charge_Time(ms)`<.8 & Handling > 40 & Impact > 60)

#Shotguns

#Shotguns are very close quarter combat weapons that will usualy 1 shot anyone within their effective range. There for we are going to want to look for one with good range, impact, and stability. 

top_shotguns <- Shotguns %>% group_by(Archetype) %>% filter(Impact > 65 & Handling > 60)

#Side Arms

#side arms are not the most effective in PVP but can still be viable in certain situations. Side arms thrive in close to medium combat and tend to have good handling, good recoil control and decent RoF.

top_sidearms <- Sidearms %>% group_by(Archetype) %>% filter(Handling > 50 & Recoil_Direction > 95)

#Breaching Grenade Launchers
#Blast Radius, Velocity and Reload speed or handling

top_bgl <- Breech_Grenade_Launchers %>% group_by(Archetype) %>% filter(Blast_Radius > 54, Velocity > 75 & Reload_Speed > 70)

#Sniper Rifles

#Sniper rifles require special ammo which means you only start with 2 shots. However they do 1 have 1 shot capabilities like other weapons that use special ammo. Sniper excel in long range combat so the specs you will want to look out for are its handling, low zoom magnification and Aim_assist(for controller players)

top_snipers <- Sniper_Rifles %>% group_by(Archetype) %>% filter(Handling > 40 & Lowest_Zoom < 55 & Aim_Assist > 60)

#Linear Fusion Rifles

#Linear Fusion rifles require special ammo and have one shot capabilities as well but they require time to charge up and unlike normal fusion rifles these only shoot one time per charge. Since these weapons excel in medium to long range you want to look out for stats like low charge time and good handling

top_linear <- Linear_Fusion_Rifles %>% group_by(Archetype) %>% filter(`Charge_Time(ms)`> 500 & Handling > 35)

#Rocket Launchers
#Blast Radius and Velocity

top_rockets <- Rocket_Launchers %>% group_by(Archetype) %>% filter(Blast_Radius > 74 & Velocity > 50)

#Heavy Grenade Launchers
#Blast Radius and Velocity

top_hgl <- Heavy_Grenade_Launchers %>% group_by(Archetype) %>% filter(Blast_Radius > 20 & Velocity > 40)

#Machine Guns
#Either high body damage and good range or high RoF and good handling

top_mg <- Machine_Guns %>% group_by(Archetype) %>% filter(Body_dmg > 29 & Range > 65)

#Swords 
#Speed and Impact

top_swords <- Swords %>% group_by(Archetype) %>% filter(Speed > 45 & Impact > 59)
top_weapons <- bind_rows(top_autos, top_bgl, top_bows, top_fusions, top_hand_cannons, top_hgl, top_linear, top_mg, top_pulse, top_rockets, top_scouts, top_shotguns, top_sidearms, top_snipers, top_subs, top_swords)

view(top_weapons)
ggplot(data = top_weapons) + geom_bar(mapping = aes(x = Energy)) + ggtitle("Energy distribution using top weapons")

ggplot(data = gun_data) + geom_bar(mapping = aes(x = Energy)) + ggtitle("Energy distribution using all weapons")

p <- top_weapons %>% ggplot(aes(Range, Stability, color = Type, text = Weapon)) + geom_point()

library(plotly)
## Warning: package 'plotly' was built under R version 4.1.3
## 
## Attaching package: 'plotly'
## The following object is masked from 'package:ggplot2':
## 
##     last_plot
## The following object is masked from 'package:stats':
## 
##     filter
## The following object is masked from 'package:graphics':
## 
##     layout
ggplotly(p)
##Graph Ideas
gun_data %>% ggplot(aes(Crit_dmg, Body_dmg)) + geom_point()
## Warning: Removed 128 rows containing missing values (geom_point).

gun_data %>% ggplot(aes(`Optimal_TtK(s)`)) + geom_histogram()
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
## Warning: Removed 289 rows containing non-finite values (stat_bin).

ggplot(data = gun_data) + 
  geom_bar(mapping = aes(x = Archetype, fill = Energy)) + ggtitle("Amount of each Archetype")